package homework;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

public class work01 {
    public static void main(String[] args) throws Exception {
        Class.forName("com.mysql.cj.jdbc.Driver");
        Connection connection = DriverManager.getConnection(
                "jdbc:mysql://localhost:3306/book_managment?useUnicode=true&characterEncoding=utf8",
                "root",
                "root"
        );
        String sql ="SELECT title,price  FROM books where price >?";
       PreparedStatement ps =  connection.prepareStatement(sql);
       ps.setDouble(1,35.00);
       ResultSet set =  ps.executeQuery();//dql
      // ps.execute();// 通用  ddl  dml dql ，一般用于ddl
      // ps.executeUpdate();// dml
        while (set.next()){
            String title = set.getString("title");
            double price = set.getDouble("price");
            System.out.println(title+":"+price);
        }
        connection.close();


    }
}
